import Vue from 'vue'
import {
  DEFAULT_THEME,
  SIDEBAR_TYPE,
  DEFAULT_MULTI_TAB
} from '@/store/mutation-types'

const app = {
  state: {
    theme: '',
    sidebar: true,
    multiTab: true
  },
  mutations: {
    TOGGLE_THEME: (state, theme) => {
      Vue.ls.set(DEFAULT_THEME, theme);
      state.theme = theme
    },
    SET_SIDEBAR_TYPE: (state, type) => {
      state.sidebar = type
      Vue.ls.set(SIDEBAR_TYPE, type)
    },
    TOGGLE_MULTI_TAB: (state, bool) => {
      Vue.ls.set(DEFAULT_MULTI_TAB, bool)
      state.multiTab = bool
    }
  },
  actions: {
    ToggleTheme ({ commit }, theme) {
      commit('TOGGLE_THEME', theme)
    },
    setSidebar ({ commit }, type) {
      commit('SET_SIDEBAR_TYPE', type)
    },
    ToggleMultiTab ({ commit }, bool) {
      commit('TOGGLE_MULTI_TAB', bool)
    }
  }
}

export default app